import {
  AccountParams,
  DeptListItem,
  MenuParams,
  RoleParams,
  DistrictParams,
  RolePageParams,
  MenuListGetResultModel,
  DeptListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel,
  DistrictListGetResultModel,
  SamplingStatItem,
} from './model/systemModel';
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { useUserStore } from '/@/store/modules/user';
const globSetting = useGlobSetting();
import axios from 'axios';
import {
  HouseListGetResultModel,
} from './model/tableModel';

enum Api {
  SurveyUnitList = '/survey-unit/list',
  PrincipalsUserList = '/admin/users/list/by-role',
  AccountList = '/admin/users/list',
  AccountListjb = '/admin/users/listjb',
  AccountListjbcj = '/admin/users/listjbcj',
  addAccountList = '/admin/users/create',
  IsAccountExist = '/admin/users/exists',
  IsAccountExistFzz = '/admin/users/exists_fzz',
  DeptList = '/admin/group-types',
  setRoleStatus = '/system/setRoleStatus',
  MenuList = '/system/getMenuList',
  RolePageList = '/role/list',
  GetAllRoleList = '/admin/role-types',
  GetDistrictList = '/admin/district-tree',
  GetDistrictCascader = '/admin/district-tree/children',
  GetDistricts = '/admin/districtTree/childrenTreeList',
  addDeptList = '/department/create',
  createVillage = '/villages/createyj',
  UploadVillage = '/villages/dynamic/UploadFile',
}

export const detailApkApi = () =>
  defHttp.get<any>({
    url: '/app-update/info',
  });

export const getSurveyUnitList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: Api.SurveyUnitList,
      params: {
        pageIndex: params.page - 1,
        limit: params.pageSize,
        ...params,
      },
    })
    .then((x) => x.items);

export const getAllSurveyUnitList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: Api.SurveyUnitList,
      params: {
        pageIndex: 0,
        limit: 100000,
      },
    })
    .then((x) => x.items);

export const getPrincipalsUserList = (roleType) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: Api.PrincipalsUserList,
      params: {
        pageIndex: 0,
        limit: 100000,
        roleType,
      },
    })
    .then((x) => x.items);

export const getAllUserList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params }).then((x) => x.items);

export const getAccountList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: Api.AccountList,
    params: {
      pageIndex: params.page - 1,
      limit: params.pageSize,
    
      ...params,
    },
  });

  export const getAllUserListjb = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountListjb, params }).then((x) => x.items);

export const getAccountListjb = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: Api.AccountListjb,
    params: {
      pageIndex: params.page - 1,
      limit: params.pageSize,
      ...params,
    },
  });


  export const getAllUserListjbcj = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountListjbcj, params }).then((x) => x.items);



  function buildDistricts1(districts_) {
    const res: any[] = [];
    if (districts_) {
      districts_.forEach((element) => {
        if (element.length > 0) {
          res.push(JSON.parse(element[element.length - 1]));
        }
      });
  
      return res;
    }
  
    return [];
  }

  export const getAccountListjbcj = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: Api.AccountListjbcj,
    params: {
      districts: buildDistricts1(params['districts_']), // Assuming this generates a single value
      pageIndex: params.page - 1,
      limit: params.pageSize,
      ...params,
    },
  });

  

export const getFireStatList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat',
    params: {
      ...params,
      reCount: false,
    },
  });
export const getFireStatListxls = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/ExportExcel',
    params: {
      ...params,
      reCount: false,
    },
  });
export const reCountFireStatList = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat',
    params: {
      ...params,
      reCount: true,
    },
  });
// 导出
export const exportExcel = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/evolvestatic/ExportExcel',
    params: {
      ...params,
    },
  });
//   //2023
//   export const getFireStatList2023 = (params: AccountParams) =>
//   defHttp.get<AccountListGetResultModel>({
//     url: '/houses/pcyh/stat',
//     params: {
//       reCount: false,
//       dfg:1,
//     },
//   });
//   export const getFireStatListxls2023 = (params: AccountParams) =>
//   defHttp.get<AccountListGetResultModel>({
//     url: '/houses/pcyh/ExportExcel',
//     params: {
//       reCount: false,
//       dfg:1,
//     },
//   });
// export const reCountFireStatList2023 = (params: any) =>
//   defHttp.get<AccountListGetResultModel>({
//     url: '/houses/pcyh/stat',
//     params: {
//       reCount: true,
//       dfg:1,
//     },
//   });

//777 315前后合并
export const getFireStatList777 = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat777',
    params: {
      reCount: false,
      ...params,
    },
  });

export const reCountFireStatList777 = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat777',
    params: {
      reCount: true,
      dfg: 1,
    },
  });

//777_after
export const getFireStatList777_after = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat314',
    params: {
      reCount: false,
      dfg: 0,
    },
  });
export const reCountFireStatList777_after = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat314',
    params: {
      reCount: true,
      dfg: 0,
    },
  });

//107 315前后合并
export const getFireStatList107 = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat107',
    params: {
      reCount: false,
      ...params,
    },
  });
export const reCountFireStatList107 = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat107',
    params: {
      reCount: true,
      dfg: 1,
    },
  });

//107_after
export const getFireStatList107_after = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat107',
    params: {
      reCount: true,
      dfg: 1,
    },
  });
export const reCountFireStatList107_after = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/pcyh/stat107',
    params: {
      reCount: true,
      dfg: 1,
    },
  });
export const getDeptList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });

export const getMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const getDistrictList = (params?: DistrictParams) =>
  defHttp.get<DistrictListGetResultModel>({ url: Api.GetDistrictList, params });
// 三级联动的组件（区、县、村）
export const getDistrictCascader = (params?: DistrictParams) =>
  defHttp.get<DistrictListGetResultModel>({ url: Api.GetDistrictCascader, params }).then((val) => {
    if (val) {
      val.forEach((element) => {
        element['_d'] = JSON.stringify({
          id: element.id,
          regionCode: element.regionCode,
          regionName: element.regionName,
        });
      });
    }

    return val;
  });
export const getDistrictCascaderList = (params?: DistrictParams) =>
  defHttp.get<DistrictListGetResultModel>({ url: Api.GetDistricts, params });


export const setRoleStatus = (id: number, status: string) =>
  defHttp.post({ url: Api.setRoleStatus, params: { id, status } });
export const createVillage = (params: any) =>
  defHttp.post({ url: Api.createVillage, params: params }, { isReturnNativeResponse: true });
export const editVillageYj = (params: any) =>
  defHttp.post(
    { url: `/villages/${params.id}/edityj`, params: params },
    { isReturnNativeResponse: true },
  );
export const editVillage = (params: any) =>
  defHttp.post(
    { url: `/villages/${params.id}/edit`, params: params },
    { isReturnNativeResponse: true },
  );
export const isAccountExist = (account: string) =>
  defHttp.get(
    { url: Api.IsAccountExist, params: { username: account } },
    { errorMessageMode: 'none' },
  );
// 非住宅 -- 核查任务管理 -- 手动抽样
export const isAccountExistFzz = (account: string) =>
  defHttp.get(
    { url: Api.IsAccountExistFzz, params: { username: account } },
    { errorMessageMode: 'none' },
  );

export const isSurveyUnitExist = (account: string) =>
  defHttp.get(
    { url: '/survey-unit/exists', params: { name: account } },
    { errorMessageMode: 'none' },
  );

export const editAccountPwd = (dept: Recordable) =>
  defHttp.post(
    { url: `/admin/users/${dept.userNumber}/pwd-reset`, params: dept, data: dept },
    { errorMessageMode: 'modal' },
  );

export const editHouseStatus = (house: Recordable) =>
  defHttp.post(
    { url: `/houses/${house.id}/pczt/edit`, data: house },
    { errorMessageMode: 'modal' },
  );
// 阳台排查  楼栋 修改状态的接口
export const editBalconyStatus = (house: Recordable) =>
  defHttp.get({
    url: `/Yt/UpdateBuildStatus?pczt=${house.pczt}&build_no=${house.build_no}`,
  });
export const editDeptList = (dept: Recordable) =>
  defHttp.post({ url: `/department/${dept.id}/edit`, params: dept }, { errorMessageMode: 'modal' });

export const addDeptList = (dept: string) =>
  defHttp.post({ url: Api.addDeptList, params: dept }, { errorMessageMode: 'modal' });

export const delDept = (dept: Recordable) =>
  defHttp.post(
    { url: `/department/${dept.id}/delete`, params: dept },
    { errorMessageMode: 'modal' },
  );

export const editAccountList = (account: Recordable) =>
  defHttp.post(
    { url: `/admin/users/${account.number}/edit`, params: account },
    { errorMessageMode: 'modal' },
  );

export const addAccountList = (account: Recordable) =>
  defHttp.post({ url: Api.addAccountList, params: account }, { errorMessageMode: 'modal' });

export const delAccount = (account: Recordable) =>
  defHttp.post(
    { url: `/admin/users/${account.number}/delete`, params: account },
    { errorMessageMode: 'modal' },
  );

  
export const fwbhjb = (account: Recordable) =>
defHttp.post(
  { url: `/admin/users/${account.id}/fwbhjb`, params: account },
   { errorMessageMode: 'modal' },
).then((x) => {console.log("x",x)});


export const fwbhjbcj = (account: Recordable) =>
defHttp.post(
  { url: `/admin/users/${account.fwbh}/fwbhjbcj`, params: account },
   { errorMessageMode: 'modal' },
    )
    .then((x) => {
      console.log('x', x);
    });
export const updateregion = (params: Recordable) =>
  defHttp.get({
    url: `/admin/users/${params.number}/updateregion`,
    params: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const placeListApi = (params: any) =>
  defHttp.get({
    url: `/houses/${params.fwbh}/baselog/list`,
    params: {
      pczt: params.pczt,
      pageIndex: params.page - 1,
      limit: params.pageSize,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const placeListFireApi = (params: any) =>
  defHttp.get({
    url: `/houses/${params.id}/baselog/list`,
    params: {
      pczt: params.pczt,
      pageIndex: params.page - 1,
      limit: params.pageSize,
      type: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
// 查看阳台 的列表
export const balconyYHListApi = (params: any) =>
  defHttp.get({
    url: `/yt/GetFromById`,
    params: {
      build_no: params.buildNo,
      pageIndex: params.page - 1,
      limit: params.pageSize,
      ...params,
      // type: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const placeListPoliceApi = (params: any) =>
//http://39.103.152.237:5005/api/v1/houses/baseInfo/baseInfoDetaile?pageIndex=0&limit=15&fwbh=110105000138491&orderBy=0&_t=1712814372054  
defHttp.get({
    url: `/houses/${params.fwbh}/place/list`,
    params: {
      pczt: params.pczt,
      pageIndex: params.page - 1,
      limit: params.pageSize,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const delPlace = (params: Recordable) =>
  defHttp.post(
    { url: `/houses/${params['houseId']}/place/${params.id}/delete`, params },
    { errorMessageMode: 'modal' },
  );
// 删除隐患阳台
export const delYhBalcony = (params: Recordable) =>
  defHttp.get({ url: `/Yt/DelZmYtFrom?id=${params.roomNo}` }, { errorMessageMode: 'modal' });

export const addSurveyUnitList = (account: Recordable) =>
  defHttp.post({ url: '/survey-unit/create', params: account }, { errorMessageMode: 'modal' });

export const editSurveyUnitList = (account: Recordable) =>
  defHttp.post(
    { url: `/survey-unit/${account.id}/edit`, params: account },
    { errorMessageMode: 'modal' },
  );

export const getSurveyUnitMngList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({
    url: `/survey-unit/${params.id}/managers/list`,
    params,
  });

export const editSurveyUnitMngList = (account: Recordable) =>
  defHttp.post(
    { url: `/survey-unit/${account.id}/managers/add`, params: account },
    { errorMessageMode: 'modal' },
  );

export const delSurveyUnit = (account: Recordable) =>
  defHttp.post(
    { url: `/survey-unit/${account.id}/delete`, params: account },
    { errorMessageMode: 'modal' },
  );

export const delSampleTasks = (account: Recordable) =>
  defHttp.post(
    { url: `/sample-tasks/${account.id}/delete`, params: account },
    { errorMessageMode: 'modal' },
  );

export const getSamplingStat = (zjfType: any) =>
  defHttp.get<SamplingStatItem>({
    url: '/sample-tasks/stat',
    params: { zjfType: zjfType },
  });
// 区县 -- 自建房数据核查 -- 我的任务包 获取抽样列表
export const getSamplingList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/sample-tasks/list',
      params: {
        pageIndex: params.page - 1,
        limit: params.pageSize,
        ...params,
      },
    })
    .then((x) => x.items);
// 消防的 市级 查询条件接口 post
export const getFireCityCountPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: {
        keyValues: [
          { key: 'cs', value: account.cs },
          { key: 'peoples', value: account.peoples },
          { key: 'rooms', value: account.rooms },
          { key: 'fistexitnum', value: account.fistexitnum },
          { key: 'stairs', value: account.stairs },
        ],
      },
    },
    { errorMessageMode: 'modal' },
  );
// 消防的 区县 查询条件接口 post
export const getFireCountPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: {
        keyValues: [
          { key: 'xzqdm', value: account.xzqdm },
          { key: 'cs', value: account.cs },
          { key: 'peoples', value: account.peoples },
          { key: 'rooms', value: account.rooms },
          { key: 'fistexitnum', value: account.fistexitnum },
          { key: 'stairs', value: account.stairs },
        ],
      },
    },
    { errorMessageMode: 'modal' },
  );
/********* 图表统计  *************/
// 排查进度统计
// get 请求  市级 (表格，中间地图,房租排查栋数的接口)
export const getTongJiList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
// post 请求 区级 (表格，中间地图,房租排查栋数的接口)
export const getTongJiPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: { keyValues: [{ key: 'xzqdm', value: account.xzqdm }] },
    },
    { errorMessageMode: 'modal' },
  );
// 房屋面积
export const getHouseArea = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);

// 场所排查统计
export const getSiteCount = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
/*****  隐患排查  ******/
// 所有隐患的(两个表格的数据、中间的地图的数据)
export const getAllDangerList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
// 严重隐患（左侧韦恩图）
export const getBadlyDangerList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
// 一般隐患（右侧韦恩图）
export const getCommonDangerList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);

// 自建出租房屋隐患录入系统汇总表(商业)
export const getBusinessList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
        ...params,
      },
    })
    .then((x) => x);
// 自建出租房屋隐患录入系统汇总表(居住)
export const getLivingList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
        ...params,
      },
    })
    .then((x) => x);
// 合并接口--消防消隐统计合并接口 -- 分项 --按隐患
export const getFireDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excutexf',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************区级统计基础信息（lnn） 2024-02-01 ********************
export const getLouDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/houses/basestatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************乡镇统计基础信息（lnn） 2024-02-01 ********************
export const getTownshipDangerList = (params: any) =>
  defHttp
    .get({
      url: '/houses/basestatic/Townshipbaselist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************乡镇统计基础信息（lnn） 2024-02-01 ********************
export const getVillageDangerList = (params: any) =>
  defHttp
    .get({
      url: '/houses/basestatic/Villagebaselist',
      params: {
        ...params,
      },
    })
    .then((x) => x);


// ******************** 自查统计*******************区级统计隐患情况（lnn） 2024-02-01 ********************
export const getYhDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/houses/yhstatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************乡镇统计隐患情况（lnn） 2024-02-01 ********************
export const getTownshipYhList = (params: any) =>
  defHttp
    .get({
      url: '/houses/yhstatic/TownshipYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************乡镇统计隐患情况（lnn） 2024-02-01 ********************
export const getVillageYhList = (params: any) =>
  defHttp
    .get({
      url: '/houses/yhstatic/VillageYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 自查统计*******************乡镇统计隐患情况******详情（lnn） 2024-02-01 ********************
export const getDetailYhList = (params: any) =>
  defHttp
    .get({
      url: '/houses/yhstatic/yhdetaile',
      params: {
        ...params,
      },
    })
    .then((x) => x);


export const getCheckVillagePStaticDetailList = (params: any) =>
  defHttp.get({
    url: '/village/evolvestatic/villagePostStaticDetail',
    params: {
      ...params,
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const villagePostStaticDetail = (params: any) =>
  defHttp.get({
    url: '/hc/evolvestatic/villagePostStaticDetail',
    params: {
      ...params,
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const villageProgreeApi = (params: any) =>
  defHttp.get({
    url: '/houses/evolvestatic/villagePostStatic',
    params: {
      ...params,
      districts: buildDistricts(params['districts_']),
      pageIndex: params.pageIndex-1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });



export const getRegion= () =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/district-tree/GetRegionTree',
    })
    .then((x) => x);




// ********************  村级统计*******************区级工作进展（lnn） 2024-03-01 ********************
export const getCheckProgress = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/village/evolvestatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  村级统计*******************乡镇工作进展（lnn）2024-03-01  ********************
export const getCheckTownshipProgress = (params: any) =>
  defHttp
    .get({
      url: '/village/evolvestatic/Townshipstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  村级统计*******************村级工作进展（lnn） 2024-03-01  ********************
export const getCheckVillageProgress = (params: any) =>
  defHttp
    .get({
      url: '/village/evolvestatic/Villagestaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);



// ********************  获取所有村的工作进展*******************村级工作进展（lnn） 2024-03-01  ********************
export const getCheckVillagePostStaticDetailList = (params: any) =>
  defHttp.get({
    url: '/village/evolvestatic/villagePostStatic',
    params: {
      ...params,
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });


// ********************  获取某栋房屋的检查情况******************村级工作进展明细（lnn） 2024-03-01  ********************
  export const getCheckHousrInfoApi = (params: any) =>
  defHttp.get({
    url: `/village/baseInfo/baseInfoDetaile`,
    params: {
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      fwbh: params.fwbh,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

  
  export const getCheckHousrDetailApi = (params: any) =>
  defHttp.get({
    url: `/village/${params.id}/restinfo`,
    params: {
      fwbh: params.id,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

  export const getCheckHousrInfoApi2 = (params: any) =>
  defHttp.get({
    url: `/village/baseInfo/baseInfoDetaile`,
    params: {
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      fwbh: params.fwbh,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
// ******************** 村级检查端统计*******************区级统计隐患情况（lnn） 2024-02-01 ********************
export const getCheckYhDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/village/yhstatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 村级检查端统计*******************乡镇统计隐患情况（lnn） 2024-02-01 ********************
export const getCheckTownshipYhList = (params: any) =>
  defHttp
    .get({
      url: '/village/yhstatic/TownshipYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 村级检查端统计*******************村级统计隐患情况（lnn） 2024-02-01 ********************
export const getCheckVillageYhList = (params: any) =>
  defHttp
    .get({
      url: '/village/yhstatic/VillageYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 村级检查端统计*******************乡镇统计隐患情况******详情（lnn） 2024-02-01 ********************
export const getCheckDetailYhList = (params: any) =>
  defHttp
    .get({
      url: '/village/yhstatic/yhdetaile',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ******************** 工作进展统计*******************lnn 2024-03-11********************

export const getInspectWorkPostExcelList = (params: any) =>
  defHttp.get<AccountListGetResultModel>({
    url: '/houses/evolvestatic/ExportExcel',
    params: {
      ...params,
    },
  });
function buildDistricts(districts_) {
  const res: any[] = [];
  if (districts_) {
    districts_.forEach((element) => {
      if (element.length > 0) {
        res.push(JSON.parse(element[element.length - 1]));
      }
    });
    return res;
  }
  return [];
}

// ******************** 某栋房屋的自查记录*******************lnn 2024-03-11********************
export const getCheckInfoApi = (params: any) =>
  defHttp.get({
    url: `/houses/baseInfo/baseInfoDetaile`,
    params: {
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      fwbh: params.fwbh,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });


// ******************** 获取自查端用户*******************lnn 2024-03-19********************
  export const getSeltUserList = (params: any) =>
  defHttp.get({
    url: '/preference/user/userlist',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
  
// ******************** 获取自查端用户工作量*******************lnn 2024-03-19********************
  export const getUserWorkStatic = (params: any) =>
  defHttp.get({
    url: '/preference/user/UserWorkStatic',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 获取检查端用户*******************lnn 2024-03-19********************
export const getCheckUserList = (params: any) =>
  defHttp.get({
    url: '/preference/checkuser/checkuserlist',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 获取检查端用户工作量*******************lnn 2024-03-19********************
export const getCheckUserWorkStatic = (params: any) =>
  defHttp.get({
    url: '/preference/checkuser/CheckUserWorkStatic',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 获取检查端用户工作量*******************lnn 2024-03-19********************
export const getHcUserWorkStatic = (params: any) =>
  defHttp.get({
    url: '/preference/hcuser/HcUserWorkStatic',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 根据区县获取当前已检查的房屋*******************lnn 2024-03-19********************
export const getUserCheckHourseList = (params: any) =>
  defHttp.get({
    url: '/village/evolvestatic/getUserCheckHourseList',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 根据区县获取当前已核查的房屋*******************lnn 2024-03-19********************
export const getUserHcHourseList = (params: any) =>
  defHttp.get({
    url: '/village/evolvestatic/getUserHcHourseList',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
//***************************获取当前区所有的用户*************************************** */
export const getXzqByCheckUserList = (params: any) =>
  defHttp.get({
    url: '/village/evolvestatic/getCheckUserList',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
export const checkuserHouselist = (params: any) =>
  defHttp.post({
    url: '/preference/checkuser/checkuserHouselist',
    params: {
      ...params,
      pageIndex: params.pageIndex,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
});
// ******************** 统计所有已拆除、不出租的房屋*******************lnn 2024-03-19********************
export const getHourseRomoveList = (params: any) =>
defHttp.get({
  url: '/village/evolvestatic/HouseRemoveList',
  params: {
    ...params,
    pageIndex: params.pageIndex-1,
    limit: params.pageSize,
    orderBy: 0,
  },
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});

// ******************** 统计所有已拆除、不出租的房屋*******************lnn 2024-05-19********************
export const getZjHourse = (params: any) =>
defHttp.get({
  url: '/village/evolvestatic/ZJHouseList',
  params: {
    ...params,
    pageIndex: params.pageIndex-1,
    limit: params.pageSize,
    orderBy: 0,
  },
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});

export const getYhHourse = (params: any) =>
defHttp.get({
  url: '/village/evolvestatic/YHZGHouseList',
  params: {
    ...params,
    pageIndex: params.pageIndex-1,
    limit: params.pageSize,
    orderBy: 0,
  },
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});

export const WZCHouseList = (params: any) =>
defHttp.get({
  url: '/village/evolvestatic/WZCHouseList',
  params: {
    ...params,
    pageIndex: params.pageIndex-1,
    limit: params.pageSize,
    orderBy: 0,
  },
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});


// ******************** 核查统计*******************区级工作进展（lnn） 2024-03-01 ********************
export const getHckProgress = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/hc/evolvestatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
 export const getHckProgressNew = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/hc/evolvestatic/staticlistNew',
      params: {
        ...params,
      },
    })
        .then((x) => x);
// ********************  核查统计*******************乡镇工作进展（lnn）2024-03-01  ********************
export const getHcTownshipProgress = (params: any) =>
  defHttp
    .get({
      url: '/hc/evolvestatic/Townshipstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  核查统计*******************村级工作进展（lnn） 2024-03-01  ********************
export const getHcVillageProgress = (params: any) =>
  defHttp
    .get({
      url: '/hc/evolvestatic/Villagestaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);



// ********************  获取所有村的核查工作进展*******************村级工作进展（lnn） 2024-03-01  ********************
export const getHcVillagePostStaticDetailList = (params: any) =>
  defHttp.get({
    url: '/hc/evolvestatic/villagePostStatic',
    params: {
      ...params,
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });





// ********************  核查获取某栋房屋的核查情况******************核查工作进展明细（lnn） 2024-03-01  ********************
export const getHcHousrInfoApi = (params: any) =>
  defHttp.get({
    url: `/hc/baseInfo/baseInfoDetaile`,
    params: {
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      fwbh: params.fwbh,
      jcly: params.jcly,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });


  export const getHcHousrDetailApi = (params: any) =>
    defHttp.get({
      url: `/hc/${params.id}/restinfo`,
      params: {
        fwbh: params.id,
      },
      headers: {
        // @ts-ignore
        ignoreCancelToken: true,
      },
    });







// 合并接口--消防消隐统计合并接口 -- 总项
export const getFireDangerAllList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: `/admin/custom-function/Get777108Data?type=${params.type_zx}&groupbyLever=${params.groupbyLever}&groupbyLever_code=${params.groupbyLever_code}`,
      // params: {
      //   // id: params.id,
      //   // groupbyLever: '0',
      //   ...params,
      // },
    })
    .then((x) => x);
// 自建房隐患统计
export const GetJyxYh = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: `/city-sample-tasks/dynamic/GetJyxYh?grouplevel=${params.groupbyLever}&region_code=${params.groupbyLever_code}&type_zx=${params.type_zx}&pczt=${params.pczt}`,
      // params: {
      //   // id: params.id,
      //   // groupbyLever: '0',
      //   ...params,
      // },
    })
    .then((x) => x);
// 合并接口--隐患分项明细表 -- 按隐患
export const getFireDangerDetailList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excutexf_pronum',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);

// 合并接口--隐患分项明细表 -- 按楼栋
export const getFireLouDetailList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excutexf_pronum_fw',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 合并接口--隐患统计(销账汇总)明细列表
export const getGeneralDetailList = (params: any) =>
  defHttp
    .get({
      url: '/admin/custom-function/GeneralDetail',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
//自建房隐患统计(销账汇总)明细列表
export const GetJyxYhDetail = (params: any) =>
  defHttp
    .get({
      url: '/city-sample-tasks/dynamic/GetJyxYhDetail',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 四清三停四建设 -- 统计
export const getThreePureList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/VillageFacilitySummary',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 四清三停四建设 -- 统计应建设
export const getThreePureListYj = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/VillageFacilitySummaryYj',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 阳台统计(按进度) -- 列表
export const getBalconyScheduleCountList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/Yt/XfYtStati',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 阳台统计(按隐患) -- 列表
export const getBalconyDangeCountList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/Yt/XfYtDanger',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 阳台统计 -- 详情
export const getBalconyCountDetailList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/Yt/XfYtDetaile',
      params: {
        // id: params.id,
        // groupbyLever: '0',
        ...params,
      },
    })
    .then((x) => x);
// 获取自建房核查统计的list  params: 规定入参的类型
// 规定返回值的类型 AccountListGetResultModel
export const getCountList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
// 住建 区县 post 方法
export const getCountPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: { keyValues: [{ key: 'xzqdm', value: account.xzqdm }] },
    },
    { errorMessageMode: 'modal' },
  );
// 住建--> 核查任务正确率统计 --> 市级
export const getInspectWorkList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);
// 住建--> 自建房数据核查 --> 区县     市级抽样核查任务（区县）获取核查任务列表 post
export const getInspectWorkPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: { keyValues: [{ key: 'xzqdm', value: account.xzqdm }] },
    },
    { errorMessageMode: 'modal' },
  );

// 公共 市级 整治排查进度统计
export const getGongAnCountList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/admin/custom-function/excute',
      params: {
        id: params.id,
      },
    })
    .then((x) => x);

// 公安 区县、街道、调查员 整治排查进度统计
export const getGongAnCountPostList = (account: Recordable) =>
  defHttp.post(
    {
      url: `/admin/custom-function/excute?id=${account.id}`,
      params: { keyValues: [{ key: 'xzqdm', value: account.xzqdm }] },
    },
    { errorMessageMode: 'modal' },
  );
export const isSamplingExist = (account: string) =>
  defHttp.get(
    { url: '/sample-tasks/exists', params: { name: account } },
    { errorMessageMode: 'none' },
  );
// 区县抽样的添加
export const addSamplingList = (account: Recordable) =>
  defHttp.post({ url: '/sample-tasks/sampling', params: account }, { errorMessageMode: 'modal' });
// 区县抽样的编辑
export const editSamplingList = (account: Recordable) =>
  defHttp.post(
    { url: `/sample-tasks/${account.id}/edit`, params: account },
    { errorMessageMode: 'modal' },
  );

export const delCitySampleTasks = (account: Recordable) =>
  defHttp.post(
    { url: `/city-sample-tasks/${account.id}/delete`, params: account },
    { errorMessageMode: 'modal' },
  );
// 非住宅 核查任务管理 -- 表格操作列 -- 删除
export const delCityFzzTasks = (account: Recordable) =>
  defHttp.post(
    { url: `/city-sample-tasks/${account.id}/delete_fzz`, params: account },
    { errorMessageMode: 'modal' },
  );
export const getCitySamplingStat = (zjfType: any) =>
  defHttp.get<SamplingStatItem>({
    url: '/city-sample-tasks/stat',
    params: { zjfType: zjfType },
  });
// 非住宅-核查任务管理(市级) -- 抽样比例
export const getCityFzzStat = () =>
  defHttp.get<SamplingStatItem>({
    url: '/city-sample-tasks/stat_fzz',
    params: {},
  });

export const getCitySamplingList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/city-sample-tasks/list',
      params: {
        pageIndex: params.page - 1,
        limit: params.pageSize,
        ...params,
      },
    })
    .then((x) => x);
// 非住宅 -- 核查任务管理查询接口
export const getCityFzzList = (params: AccountParams) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/city-sample-tasks/list_fzz',
      params: {
        pageIndex: params.page - 1,
        limit: params.pageSize,
        ...params,
      },
    })
    .then((x) => x.items);

export const isCitySamplingExist = (account: string) =>
  defHttp.get(
    { url: '/city-sample-tasks/exists', params: { name: account } },
    { errorMessageMode: 'none' },
  );
// 非住宅 （是否存在）
export const isCityFzzExist = (account: string) =>
  defHttp.get(
    { url: '/city-sample-tasks/exists_fzz', params: { name: account } },
    { errorMessageMode: 'none' },
  );
// 添加抽样任务（市级）
export const addCitySamplingList = (account: Recordable) =>
  defHttp.post(
    { url: '/city-sample-tasks/sampling-random', params: account },
    { errorMessageMode: 'modal' },
  );
// 计算总量、预计抽取 (市级)
export const countCitySampling = (account: Recordable) =>
  defHttp.post(
    { url: '/city-sample-tasks/sampling-random_count', params: account },
    { errorMessageMode: 'modal' },
  );
// 计算总量、预计抽取 (区县)
export const countSampling = (account: Recordable) =>
  defHttp.post(
    { url: '/sample-tasks/sampling_random_count', params: account },
    { errorMessageMode: 'modal' },
  );
// 非住宅 -- 核查任务管理 -- 随机抽样(新增确认)
export const addCityFzzList = (account: Recordable) =>
  defHttp.post(
    { url: '/city-sample-tasks/sampling-random_fzz', params: account },
    { errorMessageMode: 'modal' },
  );
export const addManSampling = (account: Recordable) =>
  defHttp.post(
    { url: '/city-sample-tasks/sampling-manual', params: account },
    { errorMessageMode: 'modal' },
  );
// 非住宅 -- 核查任务管理 -- 手动抽样
export const addManFzz = (account: Recordable) =>
  defHttp.post(
    { url: '/city-sample-tasks/sampling-manual_fzz', params: account },
    { errorMessageMode: 'modal' },
  );
export const appendManSampling = (params: Recordable) =>
  defHttp.post(
    { url: `/city-sample-tasks/${params.id}/samples/add`, params: params },
    { errorMessageMode: 'modal' },
  );
// 图上添加
export const addSampling = (params: Recordable) =>
  defHttp.get(
    { url: `/city-sample-tasks/houses/check-result/Add`, params: params },
    { errorMessageMode: 'modal', isReturnNativeResponse: true },
  );
export const editCitySamplingList = (account: Recordable) =>
  defHttp.post(
    { url: `/city-sample-tasks/${account.id}/edit`, params: account },
    { errorMessageMode: 'modal' },
  );
// 非住宅 -- 核查任务管理 -- 随机抽样(编辑确认)
export const editCityFzzList = (account: Recordable) =>
  defHttp.post(
    { url: `/city-sample-tasks/${account.id}/edit_fzz`, params: account },
    { errorMessageMode: 'modal' },
  );
export const addPlaceList = (dat: Recordable) =>
  defHttp.post(
    { url: `/houses/${dat.hid}/place/create`, params: dat },
    { errorMessageMode: 'modal' },
  );

export const editPlaceList = (dat: Recordable) =>
  defHttp.post(
    { url: `/houses/${dat.hid}/place/${dat.id}/edit`, params: dat },
    { errorMessageMode: 'modal' },
  );

export const submitHouse = (house: Recordable) =>
  defHttp.post({ url: `/houses/${house.houseId}/submit`, data: {} }, { errorMessageMode: 'modal' });

export const submitResidentPlace = (house: Recordable) =>
  defHttp.post(
    {
      url: `/houses/${house.houseId}/place-resident/${house.id}/submit`,
      data: {},
    },
    { errorMessageMode: 'modal' },
  );
// 提交隐患阳台
export const submitYhBalconyInfo = (params: any) =>
  defHttp.post(
    {
      url: `/Yt/SubZmYtFrom`,
      params: params,
    },
    { errorMessageMode: 'modal' },
  );
// 阳台位置的字典接口
export const getBalconyDictList = (params: any) =>
  defHttp
    .get({
      url: `/Yt/excute?id=${params.id}&param=${params.build_no}`,
      // params: {
      //   pageIndex: params.page - 1,
      //   limit: params.pageSize,
      //   ...params,
      // },
    })
    .then((x) => x);
export const submitCommercialPlace = (house: Recordable) =>
  defHttp.post(
    {
      url: `/houses/${house.houseId}/place-commercial/${house.id}/submit`,
      data: {},
    },
    { errorMessageMode: 'modal' },
  );

export const editPoliceResidentPlaceInfo = (house: Recordable) =>
  defHttp.post(
    { url: `/houses/${house.houseId}/integration/place-resident/${house.id}/edit`, data: house },
    { errorMessageMode: 'modal' },
  );

export const editPoliceCommercialPlaceInfo = (house: Recordable) =>
  defHttp.post(
    { url: `/houses/${house.houseId}/integration/place-commercial/${house.id}/edit`, data: house },
    { errorMessageMode: 'modal' },
  );

const reversals = ['aboveThreeFloorSelf', 'useIndependentSmokeAlarm', 'aboveThreeFloorsEscape'];

function calcRiskLevel(rcd: Recordable) {
  let riskLevel = 0;
  for (const key in rcd) {
    if (reversals.includes(key)) {
      if (false === rcd[key]) {
        ++riskLevel;
      }
    } else {
      if (true === rcd[key]) {
        ++riskLevel;
      }
    }
  }
  rcd['level'] = riskLevel;
}

export const editFireResidentPlaceInfo = function (house: Recordable) {
  calcRiskLevel(house);

  return defHttp.post(
    { url: `/houses/${house.houseId}/fire-safety/place-resident/${house.id}/edit`, data: house },
    { errorMessageMode: 'modal' },
  );
};

export const editFireCommercialPlaceInfo = function (house: Recordable) {
  calcRiskLevel(house);
  return defHttp.post(
    { url: `/houses/${house.houseId}/fire-safety/place-commercial/${house.id}/edit`, data: house },
    { errorMessageMode: 'modal' },
  );
};

export const submitCheckResidentPlace = function (house: Recordable) {
  calcRiskLevel(house);

  return defHttp.post(
    { url: `/houses/${house.houseId}/fire-safety/place-resident/${house.id}/check`, data: house },
    { errorMessageMode: 'modal' },
  );
};

export const submitCheckCommercialPlace = function (house: Recordable) {
  calcRiskLevel(house);
  return defHttp.post(
    { url: `/houses/${house.houseId}/fire-safety/place-commercial/${house.id}/check`, data: house },
    { errorMessageMode: 'modal' },
  );
};
// 上传图片
// 图上添加
export const uploadImgApi = (params: Recordable) =>
  defHttp.get(
    { url: `/images/UpdateReport`, params: params },
    { errorMessageMode: 'modal', isReturnNativeResponse: true },
  );

// { errorMessageMode: 'modal', isReturnNativeResponse: true },
/***
 * 上传 文件
 * file ===  formData.append('file', file);
 *
 */
export const UploadVillageApi = function (file) {
  const uriBase = `${globSetting.apiBaseUrl}${globSetting.apiUrl}`;
  const tk = useUserStore().getToken;
  return axios.post(uriBase + '/villages/dynamic/UploadFile', file, {
    headers: {
      'Content-Type': 'multipart/form-data',
      Authorization: 'Bearer ' + tk,
    },
  });
};
// ******************** 9项数据统计*******************区级统计隐患情况（lnn） 2024-02-01 ********************
export const getNineDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/yhtj/yhtjlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

export const getNineTownDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/yhtj/yhtjtownlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
export const getNineVillageDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
          url: '/yhtj/yhtjvillagelist',
          params: {
            ...params,
          },
        })
        .then((x) => x);

export const getrymjcslist = (params: any) =>
  defHttp.get({
    url: '/static/rymjcs/list',
    params: { ...params },
  });
export const getrymjcstownList = (params: any) =>
  defHttp.get({
    url: '/static/rymjcs/townlist',
    params: { ...params },
  });
export const getrymjcsvillageList = (params: any) =>
  defHttp.get({
    url: '/static/rymjcs/villagelist',
    params: { ...params },
  });
//获取未核验的房屋信息
export const getWhyfwxx = (params: any) =>
  defHttp.get({
    url: '/hc/hctj/whyfwxx',
    params: { ...params },
  });
//获取未核验的房屋信息
export const delethouseApi = (params: any) =>
  defHttp.get({
    url: '/hourse/deleteHourse',
    params: { ...params },
  });

  // ******************** 核验隐患统计*******************区级********************
export const getHYYhDangerList = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/hc/yhstatic/hystaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 核验隐患统计*******************乡镇 ********************
export const getHYTownshipYhList = (params: any) =>
  defHttp
    .get({
      url: '/hc/yhstatic/HyTownshipYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 核验隐患统计*******************村级********************
export const getHYVillageYhList = (params: any) =>
  defHttp
    .get({
      url: '/hc/yhstatic/HyVillageYhstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);
// ******************** 村级检查端统计*******************统计各级核验隐患情况*******************
export const getHYDetailYhList = (params: any) =>
  defHttp
    .get({
      url: '/hc/yhstatic/hyyhdetaile',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  房主自查情况*******************按区级统计自查情况 ********************
export const getzcProgress = (params: any) =>
  defHttp
    .get<AccountListGetResultModel>({
      url: '/houses/evolvestatic/staticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  房主自查情况*******************按乡镇统计自查情况 ********************
export const getTownshipProgress = (params: any) =>
  defHttp
    .get({
      url: '/houses/evolvestatic/Townshipstaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  房主自查情况*******************按村级统计自查情况********************
export const getVillageProgress = (params: any) =>
  defHttp
    .get({
      url: '/houses/evolvestatic/Villagestaticlist',
      params: {
        ...params,
      },
    })
    .then((x) => x);

// ********************  房主自查情况******************获取已自查或未自查的房屋台账 ********************
export const getzcStaticDetailList = (params: any) =>
  defHttp.get({
    url: '/houses/evolvestatic/villagePostStaticDetail',
    params: {
      ...params,
      pageIndex: params.pageIndex - 1,
      limit: params.pageSize,
      orderBy: 0,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
